package features;



import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import classifiers.helper.FeatureExtractionMethod;

import features.word_counter.WordCounter;


import mulan.classifier.MultiLabelOutput;
import utils.Pair;
import utils.TagClustering;
import utils.Utils;
import weka.core.Attribute;
import weka.core.Instances;


public class NominalFeatureExtractor extends FeatureExtractor {

	public NominalFeatureExtractor(WordCounter wc, FeatureExtractionMethod method) {
		super(wc,method);
	}
	
	@Override
	protected int getNumAttributes() {
		return wc.getNumWords();
	}

	@Override
	protected List<Pair<Double,Integer>> getFeatures(String line) {
		HashMap<String,Double> word_count = getWordCount(line);
		List<Pair<Double,Integer>> res = new ArrayList<Pair<Double,Integer>>(word_count.size()+5);
		for ( String word : word_count.keySet() ) {
			res.add(new Pair<Double,Integer>(1.0,wc.getWordIdx(word)));
		}
		return res;
	}
	
	@Override
	public FeatureExtractionMethod getMethod() {
		return FeatureExtractionMethod.nom;
	}

	@Override
	protected ArrayList<Attribute> getAttributes() {
		ArrayList<Attribute> attributes = new ArrayList<Attribute>();
		for ( String word : wc.getAllWords() ) 
			attributes.add(new Attribute(word,Utils.vals_01));
		return attributes;
	} 

}
